package com.winner.strategy_pattern.phoneplan;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PhonePlanController {

    // 策略 + 工厂 两行代码解决了
    // 根据不同资费套餐来查询用户的花费
    @GetMapping("/doOperation")
    public String doOperation(String phonePlanType, Integer talkTime, Integer flow){

        PhonePlanStrategy strategy1 = PhonePlanFactory.getInvokeStrategy("ICE_CREAM");
        strategy1.doOperation(35, 5400);

        PhonePlanStrategy strategy2 = PhonePlanFactory.getInvokeStrategy("TENCENT_KING_CARD");
        strategy2.doOperation(10, 15);

        PhonePlanStrategy strategy3 = PhonePlanFactory.getInvokeStrategy("SAVE_NUMBER");
        strategy3.doOperation(5, 110);
        return "success";
    }
}
